import type { Prisma } from "@prisma/generated-client";

export const createRoleOnPermission = async (
  prisma: Prisma.TransactionClient,
  data: Prisma.RoleOnPermissionCreateInput
) => {
  return prisma.roleOnPermission.create({ data });
};

export const forceDeleteRoleOnPermissionById = async (
  prisma: Prisma.TransactionClient,
  roleId: number,
  permissionId: number
) => {
  return prisma.roleOnPermission.delete({
    where: {
      roleId_permissionId: {
        roleId,
        permissionId,
      },
    },
  });
};

export const forceDeleteRoleOnPermissions = async (
  prisma: Prisma.TransactionClient,
  field: "roleId" | "permissionId",
  ids: number[]
) => {
  return prisma.roleOnPermission.deleteMany({
    where: { [field]: { in: ids } },
  });
};
